<!-- HTML header for doxygen 1.8.4-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
		<meta http-equiv="X-UA-Compatible" content="IE=9"/>
		<meta name="generator" content="Doxygen 1.8.4"/>
		<title>exceptions4c: e4c_rsc.h File Reference</title>
		<link href="tabs.css" rel="stylesheet" type="text/css"/>
		<link href="exceptions4c.css" rel="stylesheet" type="text/css" />
		<!-- <link href="sheep_016.png" rel="shortcut icon" /> -->
		<link href="" rel="shortcut icon">
		<script type="text/javascript" src="jquery.js"></script>
		<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
		<link href="exceptions4c.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
				<div id="titlearea">
					<table cellspacing="0" cellpadding="0">
						<tbody>
							<tr style="height: 56px;">
									<td id="projectlogo"><img alt="Logo" src="sheep_064.png"/></td>
									<td style="padding-left: 0.5em;">
										<div id="projectname">
											exceptions4c
											&nbsp;
											<span id="projectnumber">version 3.0</span>
										</div>
											<div id="projectbrief">An exception handling framework for C</div>
									</td>
							</tr>
						</tbody>
				</table>
			</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('e4c__rsc_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">e4c_rsc.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>exceptions4c automatic resource handling header file  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="e4c_8h.html">e4c.h</a>&quot;</code><br/>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Convenience macros for acquiring and disposing resources</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These macros let you acquire and dispose different kinds of resources according to the <em>dispose pattern</em>. </p>
</div></td></tr>
<tr class="memitem:aed2e1edbae50abc57029677111ee492a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#aed2e1edbae50abc57029677111ee492a">e4c_using_memory</a>(buffer, bytes)</td></tr>
<tr class="memdesc:aed2e1edbae50abc57029677111ee492a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Introduces a block of code with automatic acquisition and disposal of a memory buffer.  <a href="#aed2e1edbae50abc57029677111ee492a">More...</a><br/></td></tr>
<tr class="separator:aed2e1edbae50abc57029677111ee492a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab95c95244edfd564ed80fb5425e80ec5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#ab95c95244edfd564ed80fb5425e80ec5">e4c_using_file</a>(file, path, mode)</td></tr>
<tr class="memdesc:ab95c95244edfd564ed80fb5425e80ec5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Introduces a block of code with automatic acquisition and disposal of a file stream.  <a href="#ab95c95244edfd564ed80fb5425e80ec5">More...</a><br/></td></tr>
<tr class="separator:ab95c95244edfd564ed80fb5425e80ec5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae79d31fae928b7ef6bb22f8b7a760fbe"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#ae79d31fae928b7ef6bb22f8b7a760fbe">e4c_using_mutex</a>(mutex)</td></tr>
<tr class="memdesc:ae79d31fae928b7ef6bb22f8b7a760fbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Introduces a block of code with automatic acquisition and disposal of a mutex.  <a href="#ae79d31fae928b7ef6bb22f8b7a760fbe">More...</a><br/></td></tr>
<tr class="separator:ae79d31fae928b7ef6bb22f8b7a760fbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Resource handling exceptions</div></td></tr>
<tr class="memitem:acb55a7fa214c4200c62adcdf447ca453"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#acb55a7fa214c4200c62adcdf447ca453">MemoryAllocationException</a></td></tr>
<tr class="memdesc:acb55a7fa214c4200c62adcdf447ca453"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when malloc returns a null pointer.  <a href="#acb55a7fa214c4200c62adcdf447ca453">More...</a><br/></td></tr>
<tr class="separator:acb55a7fa214c4200c62adcdf447ca453"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ae78aaefa76237315f61e3f061927ca"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#a6ae78aaefa76237315f61e3f061927ca">FileException</a></td></tr>
<tr class="memdesc:a6ae78aaefa76237315f61e3f061927ca"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a file error occurs.  <a href="#a6ae78aaefa76237315f61e3f061927ca">More...</a><br/></td></tr>
<tr class="separator:a6ae78aaefa76237315f61e3f061927ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1f498fc4297b1f4cee5cb8ceb428b9a"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#af1f498fc4297b1f4cee5cb8ceb428b9a">FileOpenException</a></td></tr>
<tr class="memdesc:af1f498fc4297b1f4cee5cb8ceb428b9a"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a file cannot be opened.  <a href="#af1f498fc4297b1f4cee5cb8ceb428b9a">More...</a><br/></td></tr>
<tr class="separator:af1f498fc4297b1f4cee5cb8ceb428b9a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a469884bc55302400c6be1c2bccf38e6d"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#a469884bc55302400c6be1c2bccf38e6d">FileCloseException</a></td></tr>
<tr class="memdesc:a469884bc55302400c6be1c2bccf38e6d"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a file cannot be closed.  <a href="#a469884bc55302400c6be1c2bccf38e6d">More...</a><br/></td></tr>
<tr class="separator:a469884bc55302400c6be1c2bccf38e6d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a22790bdf41d04dd6dc4612ab66bb9e39"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#a22790bdf41d04dd6dc4612ab66bb9e39">MutexException</a></td></tr>
<tr class="memdesc:a22790bdf41d04dd6dc4612ab66bb9e39"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a mutex error occurs.  <a href="#a22790bdf41d04dd6dc4612ab66bb9e39">More...</a><br/></td></tr>
<tr class="separator:a22790bdf41d04dd6dc4612ab66bb9e39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae90b88932b045843b52ef0508bc242a6"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#ae90b88932b045843b52ef0508bc242a6">MutexLockException</a></td></tr>
<tr class="memdesc:ae90b88932b045843b52ef0508bc242a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a mutex cannot be locked.  <a href="#ae90b88932b045843b52ef0508bc242a6">More...</a><br/></td></tr>
<tr class="separator:ae90b88932b045843b52ef0508bc242a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a761a8f5296aa8638d079404442b3b285"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="e4c__rsc_8h.html#a761a8f5296aa8638d079404442b3b285">MutexUnlockException</a></td></tr>
<tr class="memdesc:a761a8f5296aa8638d079404442b3b285"><td class="mdescLeft">&#160;</td><td class="mdescRight">This exception is thrown when a mutex cannot be unlocked.  <a href="#a761a8f5296aa8638d079404442b3b285">More...</a><br/></td></tr>
<tr class="separator:a761a8f5296aa8638d079404442b3b285"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>exceptions4c automatic resource handling header file </p>
<dl class="section version"><dt>Version</dt><dd>2.0 </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Copyright (c) 2012 Guillermo Calvo</dd></dl>
<h1><a class="anchor" id="e4c_rsc_h"></a>
exceptions4c automatic resource handling header file</h1>
<p>This header file needs to be included in order to be able to use any of the automatic resource handling macros:</p>
<ul>
<li><code><a class="el" href="e4c__rsc_8h.html#aed2e1edbae50abc57029677111ee492a" title="Introduces a block of code with automatic acquisition and disposal of a memory buffer. ">e4c_using_memory</a></code></li>
<li><code><a class="el" href="e4c__rsc_8h.html#ab95c95244edfd564ed80fb5425e80ec5" title="Introduces a block of code with automatic acquisition and disposal of a file stream. ">e4c_using_file</a></code></li>
<li><code><a class="el" href="e4c__rsc_8h.html#ae79d31fae928b7ef6bb22f8b7a760fbe" title="Introduces a block of code with automatic acquisition and disposal of a mutex. ">e4c_using_mutex</a></code></li>
</ul>
<h1><a class="anchor" id="license"></a>
License</h1>
<blockquote class="doxtable">
<p>This is free software: you can redistribute it and/or modify it under the terms of the <b>GNU Lesser General Public License</b> as published by the <em>Free Software Foundation</em>, either version 3 of the License, or (at your option) any later version.</p>
<p>This software is distributed in the hope that it will be useful, but <b>WITHOUT ANY WARRANTY</b>; without even the implied warranty of <b>MERCHANTABILITY</b> or <b>FITNESS FOR A PARTICULAR PURPOSE</b>. See the <a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License</a> for more details.</p>
<p>You should have received a copy of the GNU Lesser General Public License along with this software. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>. </p>
</blockquote>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ab95c95244edfd564ed80fb5425e80ec5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define e4c_using_file</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">file, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">path, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mode&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">E4C_WITH(file, e4c_dispose_file){ \</div>
<div class="line">        file = e4c_acquire_file(path, mode); \</div>
<div class="line">        if(file == NULL){ \</div>
<div class="line">            E4C_THROW(FileOpenException, <span class="stringliteral">&quot;Could not open file: &quot;</span> #path); \</div>
<div class="line">        } \</div>
<div class="line">    }E4C_USE</div>
</div><!-- fragment -->
<p>Introduces a block of code with automatic acquisition and disposal of a file stream. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>The file to be acquired, used and then disposed </td></tr>
    <tr><td class="paramname">path</td><td>The path of the file to be opened </td></tr>
    <tr><td class="paramname">mode</td><td>The access mode for the file</td></tr>
  </table>
  </dd>
</dl>
<p>This macro lets you acquire and dispose (open and close) files according to the <em>dispose pattern</em>:</p>
<div class="fragment"><div class="line">FILE * file;</div>
<div class="line"></div>
<div class="line"><a class="code" href="e4c__rsc_8h.html#ab95c95244edfd564ed80fb5425e80ec5" title="Introduces a block of code with automatic acquisition and disposal of a file stream. ">e4c_using_file</a>(file, <span class="stringliteral">&quot;log.txt&quot;</span>, <span class="stringliteral">&quot;a&quot;</span>){</div>
<div class="line">    <span class="comment">// implicit: file = fopen(&quot;log.txt&quot;, &quot;a&quot;);</span></div>
<div class="line">    fputs(<span class="stringliteral">&quot;hello, world!\n&quot;</span>, file);</div>
<div class="line">    <span class="comment">// implicit: fclose(file);</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">FileOpenException</td><td>If <code>fopen</code> returns <code>NULL</code> </td></tr>
    <tr><td class="paramname">FileCloseException</td><td>If <code>fclose</code> does not return <em>zero</em> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aed2e1edbae50abc57029677111ee492a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define e4c_using_memory</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">buffer, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">bytes&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">E4C_WITH(buffer, e4c_dispose_memory){ \</div>
<div class="line">        buffer = e4c_acquire_memory(bytes); \</div>
<div class="line">        if(buffer == NULL){ \</div>
<div class="line">            E4C_THROW(MemoryAllocationException, \</div>
<div class="line">            <span class="stringliteral">&quot;Could not allocate memory for: &quot;</span> #buffer); \</div>
<div class="line">        } \</div>
<div class="line">    }E4C_USE</div>
</div><!-- fragment -->
<p>Introduces a block of code with automatic acquisition and disposal of a memory buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buffer</td><td>The buffer to be acquired, used and then disposed </td></tr>
    <tr><td class="paramname">bytes</td><td>The amount of memory to be allocated (in bytes)</td></tr>
  </table>
  </dd>
</dl>
<p>This macro lets you acquire and dispose memory buffers according to the <em>dispose pattern</em>:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> * buffer;</div>
<div class="line"></div>
<div class="line"><a class="code" href="e4c__rsc_8h.html#aed2e1edbae50abc57029677111ee492a" title="Introduces a block of code with automatic acquisition and disposal of a memory buffer. ">e4c_using_memory</a>(buffer, 1024){</div>
<div class="line">    <span class="comment">// implicit: buffer = malloc(1024);</span></div>
<div class="line">    memset(buffer, 0, 1024);</div>
<div class="line">    <span class="comment">// implicit: free(buffer);</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">MemoryAllocationException</td><td>If <code>malloc</code> returns <code>NULL</code> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ae79d31fae928b7ef6bb22f8b7a760fbe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define e4c_using_mutex</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mutex)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">E4C_WITH(mutex, e4c_dispose_mutex){ \</div>
<div class="line">        int result = e4c_acquire_mutex(mutex); \</div>
<div class="line">        if(result != 0){ \</div>
<div class="line">            E4C_THROW(MutexLockException, <span class="stringliteral">&quot;Could not lock mutex: &quot;</span> #mutex); \</div>
<div class="line">        } \</div>
<div class="line">    }E4C_USE</div>
</div><!-- fragment -->
<p>Introduces a block of code with automatic acquisition and disposal of a mutex. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mutex</td><td>The mutex to be locked, used and then unlocked</td></tr>
  </table>
  </dd>
</dl>
<p>This macro lets you lock and unlock mutexes according to the <em>dispose pattern</em>:</p>
<div class="fragment"><div class="line">pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;</div>
<div class="line"><span class="keywordtype">int</span> counter = 0;</div>
<div class="line"></div>
<div class="line"><a class="code" href="e4c__rsc_8h.html#ae79d31fae928b7ef6bb22f8b7a760fbe" title="Introduces a block of code with automatic acquisition and disposal of a mutex. ">e4c_using_mutex</a>(&amp;mutex){</div>
<div class="line">    <span class="comment">// implicit: pthread_mutex_lock(&amp;mutex);</span></div>
<div class="line">    counter++;</div>
<div class="line">    <span class="comment">// implicit: pthread_mutex_unlock(&amp;mutex);</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">MutexLockException</td><td>If <code>pthread_mutex_lock</code> does not return <em>zero</em> </td></tr>
    <tr><td class="paramname">MutexUnlockException</td><td>If <code>pthread_mutex_unlock</code> does not return <em>zero</em> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a class="anchor" id="a469884bc55302400c6be1c2bccf38e6d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> FileCloseException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a file cannot be closed. </p>
<p><code>FileCloseException</code> is thrown by <code><a class="el" href="e4c__rsc_8h.html#ab95c95244edfd564ed80fb5425e80ec5" title="Introduces a block of code with automatic acquisition and disposal of a file stream. ">e4c_using_file</a></code> when <code>fclose</code> does not return <em>zero</em> for whatever reason.</p>
<dl class="section user"><dt>Extends:</dt><dd>FileException </dd></dl>

</div>
</div>
<a class="anchor" id="a6ae78aaefa76237315f61e3f061927ca"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> FileException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a file error occurs. </p>
<p><code>FileException</code> is the general type of exceptions produced by failed file operations.</p>
<dl class="section note"><dt>Note</dt><dd>The specific cause of the error can be determined by checking the <code>error_number</code> of the exception; it captures the value of <code>errno</code> at the time the exception was thrown (i. e. right after <code>fopen</code> or <code>fclose</code>).</dd></dl>
<dl class="section user"><dt>Extends:</dt><dd><a class="el" href="e4c_8h.html#a4ee8b42ef10e5adf967761811823150c" title="This exception is thrown when an input/output error occurs. ">InputOutputException</a> </dd></dl>

</div>
</div>
<a class="anchor" id="af1f498fc4297b1f4cee5cb8ceb428b9a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> FileOpenException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a file cannot be opened. </p>
<p><code>FileOpenException</code> is thrown by <code><a class="el" href="e4c__rsc_8h.html#ab95c95244edfd564ed80fb5425e80ec5" title="Introduces a block of code with automatic acquisition and disposal of a file stream. ">e4c_using_file</a></code> when <code>fopen</code> returns <code>NULL</code> for whatever reason.</p>
<dl class="section user"><dt>Extends:</dt><dd>FileException </dd></dl>

</div>
</div>
<a class="anchor" id="acb55a7fa214c4200c62adcdf447ca453"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> MemoryAllocationException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when malloc returns a null pointer. </p>
<p><code>MemoryAllocationException</code> is thrown by <code><a class="el" href="e4c__rsc_8h.html#aed2e1edbae50abc57029677111ee492a" title="Introduces a block of code with automatic acquisition and disposal of a memory buffer. ">e4c_using_memory</a></code> when <code>malloc</code> returns <code>NULL</code> for whatever reason.</p>
<dl class="section user"><dt>Extends:</dt><dd><a class="el" href="e4c_8h.html#add75d60a1beb6be775c7199b58c8bf49" title="This exception is thrown when the system runs out of memory. ">NotEnoughMemoryException</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a22790bdf41d04dd6dc4612ab66bb9e39"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> MutexException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a mutex error occurs. </p>
<p><code>MutexException</code> is the general type of exceptions produced by failed mutex operations.</p>
<dl class="section user"><dt>Extends:</dt><dd><a class="el" href="e4c_8h.html#a07da936a74602281d601c171b77bf0b0" title="This is the root of the exception pseudo-hierarchy ">RuntimeException</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ae90b88932b045843b52ef0508bc242a6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> MutexLockException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a mutex cannot be locked. </p>
<p><code>MutexLockException</code> is thrown by <code><a class="el" href="e4c__rsc_8h.html#ae79d31fae928b7ef6bb22f8b7a760fbe" title="Introduces a block of code with automatic acquisition and disposal of a mutex. ">e4c_using_mutex</a></code> when <code>fopen</code> returns <code>NULL</code> for whatever reason.</p>
<dl class="section user"><dt>Extends:</dt><dd>MutexException </dd></dl>

</div>
</div>
<a class="anchor" id="a761a8f5296aa8638d079404442b3b285"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structe4c__exception__type.html">e4c_exception_type</a> MutexUnlockException</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This exception is thrown when a mutex cannot be unlocked. </p>
<p><code>MutexUnlockException</code> is thrown by <code><a class="el" href="e4c__rsc_8h.html#ae79d31fae928b7ef6bb22f8b7a760fbe" title="Introduces a block of code with automatic acquisition and disposal of a mutex. ">e4c_using_mutex</a></code> when <code>fclose</code> does not return <em>zero</em> for whatever reason.</p>
<dl class="section user"><dt>Extends:</dt><dd>MutexException </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.4-->
<!-- start footer part -->
			<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
			  <ul>
				<li class="navelem"><a class="el" href="e4c__rsc_8h.html">e4c_rsc.h</a></li>
				<li class="footer">
					<a href="https://code.google.com/p/exceptions4c/" title="exceptions4c version 3.0">
						<img src="sheep_016.png" width="16" height="16" alt="" style="vertical-align: text-bottom;" />
						<strong>exceptions4c</strong>
					</a>
					Reference Documentation
					Generated by
					<a href="http://www.doxygen.org/index.html" title="doxygen 1.8.4">
						<strong>doxygen</strong>
					</a>
				</li>
			  </ul>
			</div>
	</body>
</html>
